PowerTCP Mail for .NET
Read(Byte[],Int32,Int32,Boolean) Method
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > SegmentedStream Class > Read Method : Read(Byte[],Int32,Int32,Boolean) Method




buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of Read to completely fill the buffer
Read data from the stream until a byte array is filled.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer, _
   ByVal fill As Boolean _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As SegmentedStream
Dim buffer() As Byte
Dim offset As Integer
Dim count As Integer
Dim fill As Boolean
Dim value As Integer
 
value = instance.Read(buffer, offset, count, fill)
C# 
public int Read( 
   byte[] buffer,
   int offset,
   int count,
   bool fill
)
Managed Extensions for C++ 
public: int Read( 
   byte[]* buffer,
   int offset,
   int count,
   bool fill
) 
C++/CLI 
public:
int Read( 
   array<byte>^ buffer,
   int offset,
   int count,
   bool fill
) 

Parameters

buffer
The storage location for the received data.
offset
The zero-based position in the buffer at which to store the received data.
count
The exact number of bytes to read.
fill
Always true, use this version of Read to completely fill the buffer

Return Value

The total number of bytes read into the buffer. This will either be the value of the count parameter, or zero if the stream has closed.

Exceptions

ExceptionDescription
System.IO.IOExceptionThrown when the stream is not Readable.
System.ArgumentNullExceptionThrown when the receiving buffer is null.
System.ArgumentOutOfRangeExceptionThrown when the offset is less than zero or when count is less than or equal to zero.
System.ArgumentExceptionThrown when (offset + count) > buffer.Length.
System.IO.EndOfStreamException Thrown when the end of the stream was found before the required byte count was received. When this occurs the Available property will indicate how much data may be read and the CanRead Property will return true.

Remarks

This method reads data from the stream and returns when the provided buffer is completely full or end of stream is reached. This method is a good way to read fixed-length data. An example of this is with HTTP chunking, which occurs when the server breaks up the HTTP response into fixed-size chunks. Each chunk is preceded with a hexidecimal value notifying the receiver of the size of the data chunk to follow. Initialize a byte array to this value, then call this method to fill the byte array.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.